<?php

namespace App\Repositories;

use App\Models\DriverRecordLog;
use App\Models\Drivers;
use BobCoder\Construct\Foundation\Repository\Repository;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;


class DriverRecordLogRepository extends Repository
{
    protected $model;

    public function __construct()
    {
        $this->model = new DriverRecordLog();
    }

    /**
     * 保存信息
     * @param $params
     * @return Drivers|Collection|Model
     */
    public function saveData($params)
    {
        if (!empty($params['id'])) {
            $model = $this->find($params['id']);
        } else {
            $model = $this->model;
        }

        foreach ($params as $key => $value) {
            $model->{$key} = $value;
        }
        $model->save();

        return $model;
    }
}
